package com.huawei.appmarket.service.store.awk.card;

import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.foundation.card.gamereserve.bean.BaseDecorateAppCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.Layout;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.LayoutData;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.appmarket.framework.widget.ExpandableLayout;
import com.huawei.appmarket.framework.widget.NoAdaptRenderImageView;
import com.huawei.appmarket.service.store.awk.bean.BaseHorizontalCardBean;
import com.huawei.appmarket.service.store.awk.bean.SafeAppCardBean;
import com.huawei.appmarket.service.store.awk.widget.horizon.BaseHorizonCard;
import huawei.widget.HwTextView;
import java.util.List;
import o.azb;
import o.cdr;
import o.cfv;
import o.cfw;
import o.cgz;
import o.chd;
import o.chi;
import o.chy;
import o.chz;
import o.cia;
import o.cib;
import o.cie;
import o.cig;
import o.cki;
import o.cvt;
import o.BaseRequest;
import o.dcn;
import o.dgh;
import o.dgm;
import o.djh;
import o.Logger;
import o.dni;
import o.dof;
import o.eid;
import o.eie;
import o.epv;
import o.CollectCheck;
import o.eqx;
import o.evx;
import o.ewm.d;
import o.ewm.j;
import o.ewm.n;

public class SafeAppCard extends BaseDecorateAppCard {
    protected NoAdaptRenderImageView ʻ;
    private TextView ʻॱ;
    protected ImageView ʼ;
    private TextView ˊॱ;
    private ExpandableLayout ˋˋ;
    private TextView ˋॱ;
    private a ˋᐝ;
    private int ˌ;
    private View ˍ;
    private cdr ˎˎ;
    private BaseDetailResponse ˎˏ;
    private int ˏˎ;
    private LinearLayout ˏˏ;
    protected View ˏॱ;
    private chz ˑ;
    private TextView ͺ;
    private chd ͺॱ;
    private String ـ;
    private ImageView ॱˊ;
    private cig ॱˋ;
    private ImageView ॱˎ;
    private View ॱͺ;
    protected ImageView ॱॱ;
    private View ॱᐝ;
    private chy ᐝॱ;

    class a implements IServerCallBack {
        private cig ˊ;
        final /* synthetic */ SafeAppCard ˎ;

        public a(SafeAppCard safeAppCard, cig o_cig) {
            this.ˎ = safeAppCard;
            this.ˊ = o_cig;
        }

        public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
        }

        public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
            this.ˎ.ͺॱ = (chd) o_cvu;
            this.ˎ.ˎˏ = (BaseDetailResponse) responseBean;
            if (ˊ(this.ˎ.ˎˏ.ᐝॱ())) {
                Logger.e("SafeAppCard", "No data resources!");
                return;
            }
            this.ˎ.ˋˋ.removeAllViews();
            this.ˎ.ˋˋ.addView(this.ˎ.ˊ(this.ˎ.ˋˋ));
            if (this.ˎ.ˊᐝ instanceof SafeAppCardBean) {
                ((SafeAppCardBean) this.ˎ.ˊᐝ).ॱ(this.ˎ.ͺॱ);
                ((SafeAppCardBean) this.ˎ.ˊᐝ).ˊ(this.ˎ.ˎˏ);
                ((SafeAppCardBean) this.ˎ.ˊᐝ).ˎ(false);
            }
            if (this.ˊ != null) {
                djh.ˎ().ˊ(((SafeAppCardBean) this.ˎ.ˊᐝ).ͺˏ());
                this.ˊ.ˋ();
            }
        }

        private boolean ˊ(List<LayoutData> list) {
            if (CollectCheck.isEmpty(list) || CollectCheck.isEmpty(((LayoutData) list.get(0)).ˋ()) || !(((LayoutData) list.get(0)).ˋ().get(0) instanceof BaseHorizontalCardBean) || CollectCheck.isEmpty(((BaseHorizontalCardBean) ((LayoutData) list.get(0)).ˋ().get(0)).ʻˋ()) || ((BaseHorizontalCardBean) ((LayoutData) list.get(0)).ˋ().get(0)).ʻˋ().size() < 3) {
                return true;
            }
            return false;
        }
    }

    class c implements Runnable {
        final /* synthetic */ SafeAppCard ˊ;

        private c(SafeAppCard safeAppCard) {
            this.ˊ = safeAppCard;
        }

        public void run() {
            ((BaseHorizonCard) this.ˊ.ˎˎ.ˎ(0)).ॱॱ().ˊ();
        }
    }

    public SafeAppCard(Context context) {
        super(context);
        if (context instanceof Activity) {
            this.ˏˎ = dgm.ˎ((Activity) context);
        }
    }

    public cgz ˏ(View view) {
        ˏ((ImageView) view.findViewById(j.ʻˊ));
        ˎ((ImageView) view.findViewById(j.ﾟ));
        ॱ((TextView) view.findViewById(j.ʽ));
        ˊ((TextView) view.findViewById(j.ˋ));
        ˋ((DownloadButton) view.findViewById(j.ᵣ));
        this.ʼ = (ImageView) view.findViewById(j.ˎᵢ);
        this.ॱॱ = (ImageView) view.findViewById(j.ˏᵢ);
        this.ˊॱ = (TextView) view.findViewById(j.ॱⵈ);
        this.ʻ = (NoAdaptRenderImageView) view.findViewById(j.ᐝᵢ);
        this.ͺ = (TextView) view.findViewById(j.ᐝᴵ);
        this.ˋॱ = (TextView) view.findViewById(j.ʻՙ);
        this.ॱˊ = (ImageView) view.findViewById(j.ʻי);
        this.ॱᐝ = view.findViewById(j.ᐝﾞ);
        this.ॱᐝ.setVisibility(0);
        this.ˏॱ = view.findViewById(j.ʼᐝ);
        this.ॱˎ = (ImageView) view.findViewById(j.ˎﹺ);
        this.ʻॱ = (TextView) view.findViewById(j.ㆍʼ);
        this.ˋˋ = (ExpandableLayout) view.findViewById(j.ꓸˏ);
        this.ˍ = view.findViewById(j.ʻᐝ);
        this.ˏˏ = (LinearLayout) view.findViewById(j.ˏ);
        this.ˍ.setOnTouchListener(new OnTouchListener(this) {
            final /* synthetic */ SafeAppCard ˊ;

            {
                this.ˊ = r1;
            }

            public boolean onTouch(View view, MotionEvent motionEvent) {
                if (motionEvent.getAction() == 1) {
                    this.ˊ.ˍ.callOnClick();
                }
                return false;
            }
        });
        ʽ().setOnTouchListener(new OnTouchListener(this) {
            final /* synthetic */ SafeAppCard ˏ;

            {
                this.ˏ = r1;
            }

            public boolean onTouch(View view, MotionEvent motionEvent) {
                if (motionEvent.getAction() == 1) {
                    this.ˏ.ʽ().callOnClick();
                }
                return false;
            }
        });
        this.ˋ = (HwTextView) view.findViewById(j.ʻꜞ);
        ʽ(view);
        return this;
    }

    public void ॱ(ExpandableLayout expandableLayout) {
        this.ˋˋ = expandableLayout;
    }

    public void ˏ(CardBean cardBean) {
        if (cardBean != null) {
            super.ˏ(cardBean);
            if (cardBean instanceof SafeAppCardBean) {
                SafeAppCardBean safeAppCardBean = (SafeAppCardBean) cardBean;
                this.ـ = safeAppCardBean.v_();
                this.ˎˏ = safeAppCardBean.ᶥ();
                this.ͺॱ = safeAppCardBean.ꓸ();
                if (this.ˌ != -1) {
                    this.ˌ = djh.ˎ().ˋ(safeAppCardBean.ͺˏ());
                }
                if (ʽ(safeAppCardBean)) {
                    ॱ(safeAppCardBean);
                } else {
                    ˋ(safeAppCardBean);
                    ˊ(safeAppCardBean);
                }
                if (safeAppCardBean.ˋˋ() != null) {
                    ॱ(this.ʼ, safeAppCardBean.ˋˋ().ˊ());
                    ॱ(this.ॱॱ, safeAppCardBean.ˋˋ().ॱ());
                }
                if (safeAppCardBean.ˋˋ() == null || TextUtils.isEmpty(safeAppCardBean.ˋˋ().ˋ())) {
                    this.ॱˎ.setVisibility(8);
                } else {
                    this.ॱˎ.setVisibility(0);
                    eqx.ˏ(this.ॱˎ, safeAppCardBean.ˋˋ().ˋ(), "iconflag");
                }
                ᐝ(safeAppCardBean);
                ˋ(this.ʻॱ, safeAppCardBean.ˋʻ());
                ˏ(safeAppCardBean);
                ˎ(safeAppCardBean);
                if (ˊᐝ()) {
                    this.ॱᐝ.setVisibility(0);
                    ॱˊ();
                    return;
                }
                this.ॱᐝ.setVisibility(8);
                return;
            }
            Logger.e("SafeAppCard", "data is not safeappcard bean.");
        }
    }

    private void ˊ(SafeAppCardBean safeAppCardBean) {
        if (safeAppCardBean.ʻᐝ() == null || safeAppCardBean.ॱʾ()) {
            this.ॱˊ.setVisibility(8);
            this.ˋॱ.setVisibility(8);
            return;
        }
        String ˊ = safeAppCardBean.ʻᐝ().ˊ();
        if (dof.ˋ(ˊ)) {
            this.ॱˊ.setVisibility(8);
        } else {
            this.ॱˊ.setVisibility(0);
            eqx.ˏ(this.ॱˊ, ˊ, "head_default_icon");
        }
        this.ˋॱ.setVisibility(0);
        CharSequence ˋ = safeAppCardBean.ʻᐝ().ˋ();
        if (dof.ˋ(ˋ)) {
            this.ˋॱ.setText(this.ˋॱ.getContext().getString(n.ˊٴ));
        } else {
            this.ˋॱ.setText(ˋ);
        }
    }

    private void ॱ(SafeAppCardBean safeAppCardBean) {
        this.ʻ.setVisibility(8);
        this.ͺ.setVisibility(8);
        this.ˊॱ.setVisibility(0);
        if (ˎ((BaseDistCardBean) safeAppCardBean)) {
            this.ˊॱ.setText(this.ʼॱ.getResources().getString(n.ٴᐝ));
        } else {
            this.ˊॱ.setText(this.ʼॱ.getResources().getString(n.ߴˊ));
        }
    }

    private void ˏ(SafeAppCardBean safeAppCardBean) {
        int ʼˊ = safeAppCardBean.ʼˊ();
        if (ʼˊ < 2) {
            ʻ();
        } else if (this.ॱͺ == null) {
            eie ॱ = eid.ॱ(ʼˊ);
            if (ॱ != null) {
                this.ॱͺ = ॱ.ˏ(LayoutInflater.from(this.ʼॱ));
                this.ˏˏ.addView(this.ॱͺ);
                ॱ.ॱ(this, safeAppCardBean, this.ᐝॱ, this.ʼॱ, this.ˏˎ);
                this.ˏˏ.requestLayout();
                this.ॱͺ.setTag(safeAppCardBean.ʽˊ());
            }
        } else {
            String ʽˊ = safeAppCardBean.ʽˊ();
            if (dof.ॱ(ʽˊ) || !dof.ˎ(ʽˊ, (String) this.ॱͺ.getTag())) {
                ʻ();
            }
        }
    }

    private void ʻ() {
        if (this.ॱͺ != null) {
            this.ˏˏ.removeView(this.ॱͺ);
            this.ॱͺ = null;
        }
    }

    private void ॱˊ() {
        int ˊ = (epv.ˊ() + azb.ˊ(this.ʼॱ)) + this.ʼॱ.getResources().getDimensionPixelSize(d.ॱˊ);
        azb.ʼ(this.ॱᐝ, ˊ);
        int ˏ = azb.ˏ(this.ʼॱ);
        azb.ʼ(this.ॱᐝ, ˊ);
        azb.ॱॱ(this.ॱᐝ, ˏ);
    }

    public void ˎ(SafeAppCardBean safeAppCardBean) {
        if (this.ˎˎ == null || this.ˑ == null) {
            if (djh.ˎ().ॱ() == djh.ˎ().ˋ(safeAppCardBean.ͺˏ()) && !safeAppCardBean.ꜞ() && djh.ˎ().ˎ(safeAppCardBean.ͺˏ())) {
                this.ˋˋ.removeAllViews();
                this.ˋˋ.addView(ˊ(this.ˋˋ));
                this.ˋˋ.setVisibility(0);
                new Handler().postDelayed(new c(), 300);
                safeAppCardBean.ˎ(false);
            }
            if (!safeAppCardBean.ꜞ() && this.ॱˋ != null) {
                this.ॱˋ.ˏ();
                return;
            }
            return;
        }
        this.ˎˎ.ॱ(this.ˑ, this.ˋˋ);
        new Handler().postDelayed(new c(), 300);
    }

    public SafeAppCardBean ˊ() {
        if (this.ˊᐝ != null) {
            return (SafeAppCardBean) this.ˊᐝ;
        }
        return null;
    }

    public cdr ʼ() {
        return this.ˎˎ;
    }

    public boolean ॱॱ() {
        if (this.ˋˋ == null) {
            return false;
        }
        return this.ˋˋ.ॱ();
    }

    private void ᐝ(SafeAppCardBean safeAppCardBean) {
        if (SafeAppCardBean.APP_FROM_INTERNET.equals(safeAppCardBean.ʽˋ())) {
            ʽ().setVisibility(8);
        } else {
            ʽ().setVisibility(0);
        }
    }

    public void w_() {
        eqx.ˏ(ʼॱ(), this.ˊᐝ.ॱˌ(), "app_default_icon");
    }

    private boolean ॱ(ImageView imageView, String str) {
        if (imageView == null) {
            return false;
        }
        if (dni.ˏ(str)) {
            imageView.setVisibility(8);
            return false;
        }
        imageView.setVisibility(0);
        return true;
    }

    public void x_() {
        if (this.ˊᐝ instanceof BaseDistCardBean) {
            BaseDistCardBean baseDistCardBean = (BaseDistCardBean) this.ˊᐝ;
            if (baseDistCardBean.ͺ() == 14) {
                this.ˉ.setText(this.ʼॱ.getResources().getString(n.ߴᐝ));
                return;
            } else if (baseDistCardBean.ͺ() != 1 && baseDistCardBean.ͺ() != 3) {
                this.ˉ.setText(baseDistCardBean.ˏˏ());
                return;
            } else if (!baseDistCardBean.ॱʾ() || TextUtils.isEmpty(baseDistCardBean.showDetailUrl_)) {
                this.ˉ.setText(baseDistCardBean.ॱˎ());
                return;
            } else {
                this.ˉ.setText(baseDistCardBean.showDetailUrl_);
                return;
            }
        }
        Logger.ˋ("SafeAppCard", "bean is not BaseDistCardBean");
    }

    public boolean ˋ(TextView textView, String str) {
        if (textView == null) {
            return false;
        }
        if (this.ˊᐝ instanceof BaseCardBean) {
            BaseCardBean baseCardBean = (BaseCardBean) this.ˊᐝ;
            if (TextUtils.isEmpty(str) || (baseCardBean.ॱʾ() && !TextUtils.isEmpty(baseCardBean.showDetailUrl_))) {
                textView.setVisibility(8);
                return false;
            }
        }
        return super.ˋ(textView, str);
    }

    public void ˋ(SafeAppCardBean safeAppCardBean) {
        if (dof.ˋ(safeAppCardBean.ߴ())) {
            this.ʻ.setVisibility(8);
            this.ͺ.setVisibility(8);
            if (dof.ˋ(safeAppCardBean.ˎͺ())) {
                this.ˊॱ.setVisibility(4);
                return;
            }
            this.ˊॱ.setVisibility(0);
            this.ˊॱ.setText(safeAppCardBean.ˎͺ());
            return;
        }
        this.ˊॱ.setVisibility(8);
        this.ʻ.setVisibility(0);
        this.ͺ.setVisibility(0);
        eqx.ˏ(this.ʻ, safeAppCardBean.ՙ(), "iconflag");
        this.ͺ.setText(safeAppCardBean.ߴ());
    }

    public View ᐝ() {
        return this.ॱᐝ;
    }

    public void ˏ(cig o_cig) {
        this.ॱˋ = o_cig;
    }

    public void ᐝ(int i) {
        this.ˌ = i;
        if (this.ˊᐝ != null) {
            djh.ˎ().ॱ(((SafeAppCardBean) this.ˊᐝ).ͺˏ(), i);
        }
    }

    public void ॱ(final chy o_chy) {
        this.ᐝॱ = o_chy;
        ʽ().setDownloadListener(new cki(this) {
            final /* synthetic */ SafeAppCard ˊ;

            public void ˋ() {
                if (this.ˊ.ˊᐝ instanceof SafeAppCardBean) {
                    SafeAppCardBean safeAppCardBean = (SafeAppCardBean) this.ˊ.ˊᐝ;
                    if (safeAppCardBean.ʼˊ() == 1 && !dof.ˋ(safeAppCardBean.ㆍ())) {
                        cvt ˎ = cfv.ˎ(safeAppCardBean.ㆍ(), null, 0, 1);
                        ˎ.setServiceType_(this.ˊ.ˏˎ);
                        ˎ.ˏॱ(this.ˊ.ˏ(o_chy.ˎ(((SafeAppCardBean) this.ˊ.ˊᐝ).ͺˏ(), this.ˊ.ˊᐝ.ॱˉ())));
                        this.ˊ.ˋᐝ = new a(this.ˊ, this.ˊ.ॱˋ);
                        cfw.ˎ(ˎ, this.ˊ.ˋᐝ);
                    }
                }
            }
        });
        if (o_chy != null) {
            this.ˍ.setOnClickListener(new evx(this) {
                final /* synthetic */ SafeAppCard ˋ;

                public void ˋ(View view) {
                    dgh.ॱ("251001", "URI", this.ˋ.ˊᐝ.ॱॱ());
                    if (this.ˋ.ʻ(this.ˋ.ˊ())) {
                        o_chy.ˏ(-1, this.ˋ);
                    } else {
                        o_chy.ˏ(0, this.ˋ);
                    }
                }
            });
        }
    }

    private boolean ʻ(SafeAppCardBean safeAppCardBean) {
        if (safeAppCardBean == null || safeAppCardBean.ͺ() == 14 || safeAppCardBean.ͺ() == 16) {
            return true;
        }
        return false;
    }

    private boolean ʽ(SafeAppCardBean safeAppCardBean) {
        if (safeAppCardBean != null && safeAppCardBean.ͺ() == 14) {
            return true;
        }
        return false;
    }

    private boolean ˎ(BaseDistCardBean baseDistCardBean) {
        if (baseDistCardBean == null) {
            return false;
        }
        return dcn.ˊ().ˊ(baseDistCardBean.v_());
    }

    public View ˊ(ViewGroup viewGroup) {
        this.ˎˎ = (cdr) cib.ˋ(this.ʼॱ, ((Layout) this.ˎˏ.ʻॱ().get(0)).ॱ());
        if (this.ˎˎ != null) {
            return ˊ(this.ˎˎ, viewGroup);
        }
        Logger.ˋ("SafeAppCard", "createItemView, node == null");
        return new View(this.ʼॱ);
    }

    public View ˊ(cie o_cie, ViewGroup viewGroup) {
        View ˊ = o_cie.ˊ(LayoutInflater.from(this.ʼॱ), null);
        if (o_cie.ˊ(ˊ, viewGroup)) {
            o_cie.ˋ(this.ᐝॱ);
            o_cie.ˊ(this.ॱˋ);
            chi o_chi = new chi();
            cia o_cia = new cia(viewGroup.getContext());
            o_chi.ॱ(o_cia, this.ͺॱ, this.ˎˏ, true);
            this.ˑ = o_cia.ˏ(0);
            o_cie.ॱ(this.ˑ, viewGroup);
        }
        return ˊ;
    }

    public boolean ˊᐝ() {
        if (!(this.ˊᐝ instanceof SafeAppCardBean)) {
            return false;
        }
        int ʼˊ = ((SafeAppCardBean) this.ˊᐝ).ʼˊ();
        boolean z = ʼˊ < 2 || ʼˊ > 6;
        return z;
    }

    protected boolean ˊ(BaseDecorateAppCardBean baseDecorateAppCardBean) {
        if (baseDecorateAppCardBean.ʼˊ() != 7 || dof.ॱ(baseDecorateAppCardBean.ʻˊ())) {
            return super.ˊ(baseDecorateAppCardBean);
        }
        return true;
    }

    protected String ˎ() {
        return "gift";
    }
}
